    //链表反转
    ListNode* reverse(ListNode* head)
    {
        ListNode* newhead = NULL;
        ListNode* pcur = head;
        while(pcur)
        {
            ListNode* next = pcur->next;
            pcur->next = newhead;
            newhead = pcur;
            pcur = next;
        }
        return newhead;
    }

    //找到中间节点
    ListNode* FindMiddle(ListNode* head)
    {
        ListNode* fast = head, *slow = head;
        while(fast && fast->next)
        {
            fast = fast->next->next;
            slow = slow->next;
        }
        return slow;
    }

    bool chkPalindrome(ListNode* A)
    {
        // write code here
        ListNode* pcur = A;
        ListNode* mid = FindMiddle(A);
        ListNode* rmid = reverse(mid);
        while(pcur && rmid)
        {
            if(pcur->val != rmid->val)
            {
                return false;
            }
            rmid = rmid->next;
            pcur = pcur->next;
        }
        return true;
    }